//
//  MyTopView.m
//  jianzhik
//
//  Created by 黄健文 on 2018/8/2.
//  Copyright © 2018年 WKWebView. All rights reserved.
//

#import "myTopView.h"
#import "UINavigationController+zq_getCurrentViewNavTool.h"
#import "ZQ_GetCurrentViewNavTool.h"
@implementation MyTopView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (void)awakeFromNib
{
    [super awakeFromNib];
        NSArray *imageNames = @[@"h1",
                                @"h2",
                                 // 本地图片请填写全名
                                ];
        SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, UScreenWidth, 150) shouldInfiniteLoop:YES imageNamesGroup:imageNames];
        cycleScrollView.delegate = self;
        cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;
        cycleScrollView.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    [self.topScrollerView addSubview:cycleScrollView];
}


//- (UIViewController *)viewControllerSupportView:(UIView *)view {
//    for (UIView* next = [view superview]; next; next = next.superview) {
//        UIResponder *nextResponder = [next nextResponder];
//        if ([nextResponder isKindOfClass:[UIViewController class]]) {
//            return (UIViewController *)nextResponder;
//        }
//    }
//    return nil;
//}
//
//
//- (UINavigationController *)currentNC
//{
//    if (![[UIApplication sharedApplication].windows.lastObject isKindOfClass:[UIWindow class]]) {
//        NSAssert(0, @"未获取到导航控制器");
//        return nil;
//    }
//    UIViewController *rootViewController = self.window.rootViewController;
//    return [self getCurrentNCFrom:rootViewController];
//}
//
////递归
//- (UINavigationController *)getCurrentNCFrom:(UIViewController *)vc
//{
//    if ([vc isKindOfClass:[UITabBarController class]]) {
//        UINavigationController *nc = ((UITabBarController *)vc).selectedViewController;
//        return [self getCurrentNCFrom:nc];
//    }
//    else if ([vc isKindOfClass:[UINavigationController class]]) {
//        if (((UINavigationController *)vc).presentedViewController) {
//            return [self getCurrentNCFrom:((UINavigationController *)vc).presentedViewController];
//        }
//        return [self getCurrentNCFrom:((UINavigationController *)vc).topViewController];
//    }
//    else if ([vc isKindOfClass:[UIViewController class]]) {
//        if (vc.presentedViewController) {
//            return [self getCurrentNCFrom:vc.presentedViewController];
//        }
//        else {
//            return vc.navigationController;
//        }
//    }
//    else {
//        NSAssert(0, @"未获取到导航控制器");
//        return nil;
//    }
//}


@end
